#include "mydialog.h"
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>

MyDialog::MyDialog(QWidget *parent)
        : QDialog(parent)
{
    setWindowTitle("MyDialog");

    lineEdit = new QLineEdit(this);
    confirmButton = new QPushButton("确认", this);

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(lineEdit);
    layout->addWidget(confirmButton);

    connect(confirmButton, &QPushButton::clicked, this, &MyDialog::onConfirmClicked);
}

void MyDialog::onConfirmClicked()
{
    QString text = lineEdit->text();
    emit sendData(text);  // 发送信号，把文本传出去
    accept();  // 关闭对话框，返回QDialog::Accepted
}
